﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace BingVis.SilverlightClient
{
    public static class FareViewUtility
    {
        public static ObservableCollection<FareViewModel> EmptyQuarterHoursList = GenerateEmptyList(0, 15, 30, 45);
        //public static ObservableCollection<FareViewModel> EmptyHalfHoursList = GenerateEmptyList(0, 30);
        //public static ObservableCollection<FareViewModel> EmptyHoursList = GenerateEmptyList(0);

        private static ObservableCollection<FareViewModel> GenerateEmptyList(params int[] mins)
        {
            var result = new ObservableCollection<FareViewModel>();
            var currTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 4, 0, 0, 0);
            var endTime = currTime.AddHours(22);

            while (currTime < endTime)
            {
                currTime = GetNextMinute(currTime, mins);
                result.Add(new FareViewModel(currTime));
                currTime = currTime.AddMinutes(1);
            }

            return result;
        }

        private static DateTime GetNextMinute(DateTime currTime, params int[] mins)
        {
            if (mins.Contains(currTime.Minute))
            {
                return currTime;
            }

            return GetNextMinute(currTime.AddMinutes(1), mins);
        }
    }
}
